return {
  "stevearc/conform.nvim",
  dependencies = {
    "williamboman/mason.nvim",
  },
  opts = {
    formatters_by_ft = {
      lua = { "stylua" },
      python = { "isort", "black" },
      -- rust = { "rust-analyzer", lsp_format = "fallback" },
      toml = { "templ" },
      yaml = { "yamlfmt" },
    },
  },
  config = function(_, opts)
    local registry = require("mason-registry")

    -- 收集所有格式化工具名称（自动去重）
    local formatters = {}
    for _, ft_formatters in pairs(opts.formatters_by_ft) do
      for _, formatter in ipairs(ft_formatters) do
        if type(formatter) == "string" then -- 确保是字符串类型
          formatters[formatter] = true
        end
      end
    end

    -- 安装每个格式化工具
    for formatter_name in pairs(formatters) do
      local ok, package = pcall(registry.get_package, formatter_name)
      if ok and not package:is_installed() then
        package:install()
      end
    end
  end
}
